def findMax(matrix): # DO NOT modify this line 
    max_val = max(num for row in matrix for num in row)
    coords = []
    for i in range(len(matrix)):
        row = matrix[i]
        for j in range(len(row)):
            if row[j] == max_val:
                coords.append((i,j))
    return (max_val,tuple(coords)) # You can modify or delete this line

# === DO NOT modify the code below === 
def main():
    n = eval(input())
    matrix = []
    for i in range(n):
        row = [ eval(x) for x in input().split() ]
        matrix.append(row)
    max_value, max_indexes = findMax(matrix)
    print(max_value)
    for item in max_indexes:
        print(item[0],item[1],sep=',')
    
if __name__ == "__main__":
    main()
# === DO NOT modify the code above ===